package com.bluesun.fileSystem;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

import static com.bluesun.fileSystem.fileSystem.*;

public class demo {
    public static void main(String[] args) throws IOException {
        ArrayList<String> array = new ArrayList<String>();
        while (true) {
            Scanner sc = new Scanner(System.in);
            String pan = sc.next();

            if (pan.equals("cd")) {
                Scanner scc = new Scanner(System.in);
                String path = sc.next();
                array.add(open(path));
            } else {
                if (pan.equals("cd..")) {
                    int size = array.size() - 1;
                    array.add(retu(array.get(size)));
                } else {
                    if (pan.equals("touch")) {
                        Scanner scc = new Scanner(System.in);
                        String path = sc.next();
                        int size = array.size() - 1;
                        array.add(creat(array.get(size), path));
                    } else {
                        if (pan.equals("delete")) {
                            Scanner scc = new Scanner(System.in);
                            String path = sc.next();
                            int size = array.size() - 1;
                            array.add(delete(array.get(size), path));
                        } else {
                            if (pan.equals("mkdir")) {
                                Scanner scc = new Scanner(System.in);
                                String path = sc.next();
                                int size = array.size() - 1;
                                array.add(creatD(array.get(size), path));
                            } else {
                                if (pan.equals("mv")) {
                                    Scanner scc = new Scanner(System.in);
                                    String name = sc.next();
                                    Scanner sccc = new Scanner(System.in);
                                    String path = sc.next();
                                    int size = array.size() - 1;
                                    array.add(mv(array.get(size), name, path));
                                } else {
                                    if (pan.equals("ls")) {
                                        int size = array.size() - 1;
                                        array.add(ls(array.get(size)));
                                    } else {
                                        if (pan.equals("cat")) {
                                            Scanner scc = new Scanner(System.in);
                                            String name = sc.next();
                                            int size = array.size() - 1;
                                            array.add(cat(array.get(size), name));
                                        } else {
                                            if (pan.equals("wr")) {
                                                Scanner scc = new Scanner(System.in);
                                                String name = sc.next();
                                                int size = array.size() - 1;
                                                array.add(wr(array.get(size), name));
                                            } else {
                                                if (pan.equals("exit")) {
                                                    break;
                                                } else {
                                                    System.out.println("输入了错误指令，请重新输入");
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }


        }


    }
}
